<template>
  <div class="instoveReport">
    <div class="card-title">
      <div class="text">装炉</div>
      <div class="code">{{form.stoveTime}} / {{form.totalNumber}}支 / {{form.totalWeight}}吨</div>
    </div>
    <!-- <tables :redColor="true" :tableTypes="items" :tableData="tableTop"></tables> -->
    <div class="tableClass">
      <table>
        <tr class="table_key">
          <td>加工单位</td>
          <td>种类/规格</td>
          <td>数量</td>
          <td>长度</td>
          <td>单重</td>
          <td>重量</td>
        </tr>
        <tr class="table_value" v-for="item in form.stoveReport" :key="item._id">
          <td>{{item.processUnit}}</td>
          <td>{{item.type}} {{item.specification}}</td>
          <td>{{item.number==0?'':item.number}}</td>
          <td>{{item.length==0?'':item.length}}</td>
          <td>{{item.singleWeight==0?'':item.singleWeight}}</td>
          <td>{{item.weight==0?'':item.weight}}</td>
        </tr>
      </table>
    </div>
    <!--  -->
    <div class="card-title">
      <div class="text">送电</div>
      <div class="code">{{form.electric.startElectricTime}}</div>
    </div>
    <div class="card-header card-header-center">
      <table>
        <tr class="table_key">
          <td colspan='2'>总第炉数</td>
          <td colspan='2'>送电开始功率</td>
          <td colspan='2'>计划电量</td>
          <td colspan='2'>计划电量</td>
        </tr>
        <tr class="table_value">
          <td colspan='2'>{{form.electric.totalStoveNum}}</td>
          <td colspan='2'>{{form.electric.startPower}}</td>
          <td colspan='2'>{{form.electric.plannedElectricity}}</td>
          <td colspan='2'>{{form.electric.plannedElectricity}}</td>
        </tr>
        <tr class="table_key">
          <td colspan='2'>装炉柱数</td>
          <td colspan='2'>单柱串接</td>
          <td colspan='2'>截面</td>
          <td colspan='2'>电密</td>
        </tr>
        <tr class="table_value">
          <td colspan='2'>{{form.electric.stoveColumnNum}}</td>
          <td colspan='2'>{{form.electric.oneColumnStrand}}</td>
          <td colspan='2'>{{form.electric.section}}</td>
          <td colspan='2'>{{form.electric.denseElectricity}}</td>
        </tr>
        <tr class="table_key">
          <td colspan='2'>位移要求</td>
          <td colspan='2'>配重</td>
          <td colspan='2'>保温料</td>
          <td colspan='2'>装炉方式</td>
        </tr>
        <tr class="table_value">
          <td colspan='2'>{{form.electric.displacementLess}}</td>
          <td colspan='2'>{{form.electric.counterweight}}</td>
          <td colspan='2'>{{form.electric.keepWarmMaterial}}</td>
          <td colspan='2'>{{form.electric.stoveWay}}</td>
        </tr>
        <tr class="table_value" v-for="item in 4" :key="item" >
          <td colspan='2'>{{(item-1)*6}}-{{(item-1)*6+6}}h</td>
          <td>{{form.electric.powerTime[0 + (item-1)*6].power}}</td>
          <td>{{form.electric.powerTime[1 + (item-1)*6].power}}</td>
          <td>{{form.electric.powerTime[2 + (item-1)*6].power}}</td>
          <td>{{form.electric.powerTime[3 + (item-1)*6].power}}</td>
          <td>{{form.electric.powerTime[4 + (item-1)*6].power}}</td>
          <td>{{form.electric.powerTime[5 + (item-1)*6].power}}</td>
        </tr>
      </table>
    </div>
    <div class="card-title">
      <div class="text">停电</div>
      <div class="code">{{form.electric.stopElectricTime}}</div>
    </div>
    <div class="card-header card-header-center">
      <table>
        <tr class="talbe_key">
          <td colspan='2'>直流电压</td>
          <td colspan='2'>直流电流</td>
          <td colspan='2'>起始炉阻</td>
          <td colspan='2'>停电功率</td>
          <td colspan='2'>停炉炉阻</td>
          <td colspan='2'>吨耗</td>
        </tr>
        <tr class="table_value">
          <td colspan='2'>{{form.electric.voltage==0?'':form.electric.voltage}}</td>
          <td colspan='2'>{{form.electric.electricCurrent==0?'':form.electric.electricCurrent}}</td>
          <td colspan='2'>{{form.electric.startStoveResistance==0?'':form.electric.startStoveResistance}}</td>
          <td colspan='2'>{{form.electric.stopPower==0?'':form.electric.stopPower}}</td>
          <td colspan='2'>{{form.electric.stopStoveResistance==0?'':form.electric.stopStoveResistance}}</td>
          <td colspan='2'>{{form.electric.tonConsumption==0?'':form.electric.tonConsumption}}</td>
        </tr>
        <tr class="talbe_key">
          <td colspan='2'>实际电量</td>
          <td colspan='2'>尖峰</td>
          <td colspan='2'>高峰</td>
          <td colspan='2'>平段</td>
          <td colspan='2'>谷电</td>
        </tr>
        <tr class="table_value">
          <td colspan='2'>{{form.electric.actualElectricity==0?'':form.electric.actualElectricity}}</td>
          <td colspan='2'>{{form.electric.specialPowerTime[0].power==0?'':form.electric.specialPowerTime[0].power}}</td>
          <td colspan='2'>{{form.electric.specialPowerTime[1].power==0?'':form.electric.specialPowerTime[1].power}}</td>
          <td colspan='2'>{{form.electric.specialPowerTime[2].power==0?'':form.electric.specialPowerTime[2].power}}</td>
          <td colspan='2'>{{form.electric.specialPowerTime[3].power==0?'':form.electric.specialPowerTime[3].power}}</td>
        </tr>
      </table>
    </div>
  </div>
</template>

<script>
// import tables from '@/components/tables/index.vue'
import { graphiteReportGet } from '@/api/graApi.js'
export default {
  components: {
  },
  props: {
    stoveCode: {
      type: String,
      default () {
        return ''
      }
    },
    getTime: {
      type: String,
      default () {
        return ''
      }
    }
  },
  data () {
    return {
      form: {
        electric: {
          powerTime: [
            { power: '' }
          ],
          specialPowerTime: [
            { power: '' },
            { power: '' },
            { power: '' },
            { power: '' },
            { power: '' }
          ]
        }
      }
    }
  },
  computed: {

  },
  created () {
    for (let index = 0; index < 24; index++) {
      this.form.electric.powerTime.push({})
    }
  },
  mounted () {
    this.getData()
  },
  methods: {
    getCode () {
      var time = this.getTime
      time = time.replace(/-/g, '')
      time = time.replace(/\s/g, '')
      time = time.replace(/:/g, '')
      time = time.slice(0, -2)
      // console.log('time', time)
      const code = 'SMH' + time
      return code
    },
    timeSet (time) {
      var value = time
      return value.slice(5, -3)
    },
    getData () {
      const startTime = this.getTime
      var dateEnd = new Date()
      this.year = dateEnd.getFullYear()
      this.month = dateEnd.getMonth() < 10 ? '0' + (dateEnd.getMonth() + 1) : dateEnd.getMonth() + 1
      this.date = dateEnd.getDate()
      this.hour = dateEnd.getHours() < 10 ? '0' + dateEnd.getHours() : dateEnd.getHours()
      this.minute = dateEnd.getMinutes() < 10 ? '0' + dateEnd.getMinutes() : dateEnd.getMinutes()
      this.second = dateEnd.getSeconds() < 10 ? '0' + dateEnd.getSeconds() : dateEnd.getSeconds()
      const endTime = this.year + '-' + this.month + '-' + this.date + ' ' + this.hour + ':' + this.minute + ':' + this.second
      const payload = {
        startTime: startTime,
        endTime: endTime
      }
      graphiteReportGet(payload).then(res => {
        // console.log('当前炉数据', res)
        if (!res.data.data.pageData) {
          // this.$message('当前炉未上传Excel')
        }
        var form = res.data.data.pageData[0].stove
        this.form = form
      })
    },
    getRowClass ({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return 'background: rgb(48,52,61);color: rgb(221,224,232);font-weight: unset;font-size: 12px;padding-left: 0px'
      } else {
        return ''
      }
    }
  }
}
</script>

